## No trace type specified:
## Based on info supplied, a 'scatter' trace seems appropriate.
## Read more about this trace type -> https://plot.ly/r/reference/#scatter
## No trace type specified:
## Based on info supplied, a 'bar' trace seems appropriate.
## Read more about this trace type -> https://plot.ly/r/reference/#bar
Analysis
nyc.avg.rate <- nyc.covid19.mask %>%
select("zip", "date","area", "COVID_CASE_RATE") %>%
dplyr::group_by(zip) %>%
dplyr::arrange(zip, date) %>%
mutate(rate = (COVID_CASE_RATE - lag(COVID_CASE_RATE))/lag(COVID_CASE_RATE)) %>%
summarise(avg_rate = mean(rate, na.rm = TRUE))
## `summarise()` ungrouping output (override with `.groups` argument)
nyc.avg.rate.mask <- left_join(nyt.data, nyc.avg.rate, by ="zip") %>%
mutate(obs_mask = 1 - obs_mask)
plot_ly(nyc.avg.rate.mask,
x = ~area,
y = ~obs_mask,
type = 'scatter',
mode = 'markers',
name = 'Mask Rate',
visible = T) %>%
add_trace(nyc.avg.rate.mask, y = ~avg_rate, name = 'Avg. Change Rate', visible = T) %>%
layout(
title = 'Observed Mask Rates & COVID 19 Positive Rates by Area',
showlegend = TRUE,
yaxis = list(title = "% of Masks Observed/COVID 19 Positive Rate",tickformat = "%"),
xaxis = list(title = "Area"),
hovermode = 'compare'
)